package domain

import (
	"vrcm/src/vrcm/common/models"
)

type Certificate struct {
	models.Model

	TenantId         string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	CertificateId    string `json:"certificate_id" gorm:"type:varchar(100);comment:证书id"`
	CertificateName  string `json:"certificate_name" gorm:"type:varchar(100);comment:证书名称"`
	CertificateInfo  string `json:"certificate_info" gorm:"type:varchar(100);comment:证书消息"`
	ValidFrom        int64  `json:"valid_from" gorm:"type:int;comment:证书认证开始时间"`
	ValidTo          int64  `json:"valid_to" gorm:"type:int;comment:证书认证结束时间"`
	PublicKey        string `json:"public_key" gorm:"type:varchar(300);comment:公钥"`
	PrivateKey       string `json:"private_key" gorm:"type:varchar(300);comment:私钥"`
	CertificateState int    `json:"certificate_state" gorm:"type:tinyint;comment:1正常 2即将过期 3已过期"`
	CertId           string `json:"cert_id" gorm:"type:varchar(300);comment:""`
	models.ModelTime
	models.ControlBy
}

func (Certificate) TableName() string {
	return "certificate"
}

func (e *Certificate) Generate() models.ActiveRecord {
	o := *e
	return &o
}

func (e *Certificate) GetId() interface{} {
	return e.Id
}

type CertificateModel struct {
	Certificate        Certificate         `json:"certificate" comment:""`
	CertificateDomains []CertificateDomain `json:"certificate_domain" comment:""`
}

type CertificatePageModel struct {
	Certificate        Certificate    `json:"certificate" comment:""`
	CertificateDomains []DomainConfig `json:"certificate_domain" comment:""`
	AuthorizeDomains   []DomainConfig `json:"authorize_domains" comment:""`
}
